package com.itheima.stock.job;

import com.itheima.stock.service.StockTimerTaskService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.checkerframework.checker.units.qual.A;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * xxl-job任务执行器的bean
 */
@Component
public class StockJob {

    @Autowired
    private StockTimerTaskService stockTimerTaskService;
    /**
     * 1、简单任务示例（Bean模式）
     */
    @XxlJob("myJobHandler")
    public void demoJobHandler() throws Exception {
        XxlJobHelper.log("XXL-JOB, Hello World.");

    //    System.out.println("当前时间："+ DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
        // default success
    }

    /**
     * 定时采集a股大盘数据
     * 对不同的股票数据，定义不同的采集任务，解耦，方便维护
     */

    @XxlJob("getInnerMaskInfo")
    public void getInnerMaskInfo()  {
        stockTimerTaskService.getInnerMarketInfo();

    }


    /**
     * 定时采集个股大盘数据
     * 对不同的股票数据，定义不同的采集任务，解耦，方便维护
     */

    @XxlJob("getStockRtIndex")
    public void getStockRtIndex()  {
        stockTimerTaskService.getStockRtIndex();

    }
}
